package sf01.studentmngmsystem.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sf01.studentmngmsystem.entity.Teacher;
import sf01.studentmngmsystem.mapper.TeacherMapper;
import sf01.studentmngmsystem.service.TeacherService;

@Service
public class TeacherServiceImpl implements TeacherService {
    
    @Autowired
    private TeacherMapper teacherMapper;
    
    @Override
    public Teacher login(String username, String password) {
        // 根据用户名查找教师
        Teacher teacher = teacherMapper.findByUsername(username);
        
        if (teacher == null) {
            return null; // 用户不存在
        }
        
        // 验证密码
        if (teacher.getPassword().equals(password)) {
            return teacher;
        }
        
        return null; // 密码错误
    }
    
    @Override
    public Teacher findById(Long id) {
        return teacherMapper.findById(id);
    }
}